﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace ChuanPlus
{
    public class Invoice : XPLiteObject
    {
        string fInvoiceNo;
        [Key]
        [Size(10)]
        public string InvoiceNo
        {
            get { return fInvoiceNo; }
            set { SetPropertyValue<string>("InvoiceNo", ref fInvoiceNo, value); }
        }
        Supplier fSupplierID;
        public Supplier SupplierID
        {
            get { return fSupplierID; }
            set { SetPropertyValue<Supplier>("SupplierID", ref fSupplierID, value); }
        }
        DateTime fInvoiceDate;
        public DateTime InvoiceDate
        {
            get { return fInvoiceDate; }
            set { SetPropertyValue<DateTime>("InvoiceDate", ref fInvoiceDate, value); }
        }
        string fContractNo;
        [Size(20)]
        public string ContractNo
        {
            get { return fContractNo; }
            set { SetPropertyValue<string>("ContractNo", ref fContractNo, value); }
        }
        string fTODelivery;
        public string TODelivery
        {
            get { return fTODelivery; }
            set { SetPropertyValue<string>("TODelivery", ref fTODelivery, value); }
        }
        string fTOPayment;
        public string TOPayment
        {
            get { return fTOPayment; }
            set { SetPropertyValue<string>("TOPayment", ref fTOPayment, value); }
        }
        DateTime fExpDate;
        public DateTime ExpDate
        {
            get { return fExpDate; }
            set { SetPropertyValue<DateTime>("ExpDate", ref fExpDate, value); }
        }
        string fBankAccount;
        [Size(50)]
        public string BankAccount
        {
            get { return fBankAccount; }
            set { SetPropertyValue<string>("BankAccount", ref fBankAccount, value); }
        }
        string fRemitTo;
        [Size(50)]
        public string RemitTo
        {
            get { return fRemitTo; }
            set { SetPropertyValue<string>("RemitTo", ref fRemitTo, value); }
        }
        double fTotal;
        public double Total
        {
            get { return fTotal; }
            set { SetPropertyValue<double>("Total", ref fTotal, value); }
        }
        [Association("Invoice-User")]
        Users fCreatedBy;
        public Users CreatedBy
        {
            get { return fCreatedBy; }
            set { SetPropertyValue<Users>("CreatedBy", ref fCreatedBy, value); }
        }
        [Association("Invoice-User")]
        Users fUpdatedBy;
        public Users UpdatedBy
        {
            get { return fUpdatedBy; }
            set { SetPropertyValue<Users>("UpdatedBy", ref fUpdatedBy, value); }
        }
        [Association("Invoice-InvoiceDetails")]
        public XPCollection<InvoiceDetails> InvoiceDetails  { get { return GetCollection<InvoiceDetails>("InvoiceDetails"); } }
        string fStatus;
        public string Status
        {
            get { return fStatus; }
            set { SetPropertyValue<string>("Status", ref fStatus, value); }
        }

        public Invoice(Session session) : base(session) { }
        public Invoice() : base(Session.DefaultSession) { }
        /// <summary>
        /// Initializes a new instance of the Invoice class.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="fInvoiceNo"></param>
        /// <param name="fSupplierID"></param>
        /// <param name="fInvoiceDate"></param>
        /// <param name="fContractNo"></param>
        /// <param name="fTODelivery"></param>
        /// <param name="fTOPayment"></param>
        /// <param name="fExpDate"></param>
        /// <param name="fBankAccount"></param>
        /// <param name="fRemitTo"></param>
        /// <param name="fTotal"></param>
        /// <param name="fCreatedBy"></param>
        /// <param name="fUpdatedBy"></param>
        public Invoice(Session session, string fInvoiceNo, Supplier fSupplierID, DateTime fInvoiceDate, string fContractNo, string fTODelivery, string fTOPayment, DateTime fExpDate, string fBankAccount, string fRemitTo, double fTotal, Users fCreatedBy, Users fUpdatedBy, string fStatus)
            : base(session)
        {
            this.fInvoiceNo = fInvoiceNo;
            this.fSupplierID = fSupplierID;
            this.fInvoiceDate = fInvoiceDate;
            this.fContractNo = fContractNo;
            this.fTODelivery = fTODelivery;
            this.fTOPayment = fTOPayment;
            this.fExpDate = fExpDate;
            this.fBankAccount = fBankAccount;
            this.fRemitTo = fRemitTo;
            this.fTotal = fTotal;
            this.fCreatedBy = fCreatedBy;
            this.fUpdatedBy = fUpdatedBy;
            this.fStatus = fStatus;
        }
        public override void AfterConstruction() { base.AfterConstruction(); }
    }
}
